// components/GoodsSpec/index.js
import Toast from '@vant/weapp/toast/toast';
import { exceedMessageTip, isDeferConfirmWay } from '../../utils/hooks';
import { getDatetime } from '../../utils/util';
const $api = require('../../request/api').API;
const app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    show: {
      type: Boolean
    },
    goodsId: {
      type: String
    },
    beeperId: {
      type: Number || String,
      value: ''
    },
    shopCartPosition: {
      type: Object
    }
  },
  /**
   * 组件的初始数据
   */
  data: {
    // 同一商品不同规格对象，里面的key是id组合起来的
    variantMap: null,
    // 关联产品
    relationGoodsList: [],
    // 规格列表
    specList: [],
    // 数量
    nums: 1,
    // 活动产品可享受的优惠数量
    activeNums: '',
    // 活动产品可享受的折扣
    activeDiscount: '',
    // 价格
    salePrice: 0,
    // 规格
    specVal: '',
    variantId: '',
    deposit: '',
    startFee: '',
    // 变体的sku
    sku: '',
    mainImg: '',
    specDesc: '',
    goodsInfo: null,
    introduce: '',
    goodsImage: '',
    // 获取所有的图片规格列表
    imgList: [],
    // 套餐组合
    goodsComboList: [],
    showNums: true,
    // 图片的索引
    imgIndex: 0,
    showImgePreivew: false,
    dotClientX: '',
    dotClientY: '',
    showDot: false,
    addAnimation2: '',
    goodsFormList: []
    // 表单一些特殊信息
  },
  observers: {
    async show(val) {
      if (!val) return;
      this.setData({
        relationGoodsList: [],
        specList: [],
        goodsComboList: [],
        variantMap: null,
        nums: 1,
        showNums: true,
        activeDiscount: '',
        activeNums: '',
        sku: '',
        goodsInfo: null,
        goodsFormList: []
      });

      // 先获取产品信息
      await this.getGoodsInfo();
      const { goodsInfo, beeperId } = this.data;
      if (goodsInfo.variantState == 2) {
        // variantState为2表示多规格才调用这个，是一表示单规格
        this.getSpec();
      } else if (goodsInfo.goodsType == 2) {
        // 如果goodsType为2就表示是套餐组合
        this.getGoodsCombo();
      } else {
        // 如果是普通产品直接获取价格
        this.countPrice();
      }
      if (beeperId) {
        // 呼叫器存在就查找关联产品
        this.getRelationGoods();
      }
      if (goodsInfo.attrMark) {
        this.getFormInfo(goodsInfo, true);
      }
      // const {goodsId,serverId} = this.data.goodsInfo
    }
  },
  /**
   * 组件的方法列表
   */
  methods: {
    // 获取产品信息
    async getGoodsInfo() {
      let res = await $api.getGoodsInfo({ id: this.data.goodsId });
      let data = res.data.data;
      this.setData({
        goodsInfo: data,
        goodsImage: data.goodsImages.find(item => item.mainFlag).url,
        salePrice: data.salePrice
      });
    },
    // 获取商品不同规格
    getSpec() {
      $api.getSpecByGoodsId({ goodsId: this.data.goodsId }).then(res => {
        let data = res.data.data;
        let sku = data.defaultVariant.sku;
        let specList = data.specList;
        let variantMap = data.variantMap;
        // 这里先把所有的图片全部保存下来后面要使用
        sku.split(':').forEach(item => {
          specList.forEach((item2, index) => {
            item2.specValList.find(item3 => {
              if (item3.specVal == item) {
                item3.selected = true;
                return true;
              }
            });
          });
        });
        this.setData({
          specList,
          variantMap,
          sku,
          variantId: data.defaultVariant.variantId,
          goodsInfo: data.goods
        });

        this.judgeOverSold();
        this.getImgList();
      });
    },
    // 获取关联产品
    getRelationGoods() {
      const params = {
        beeperId: this.data.beeperId,
        goodsId: this.data.goodsId,
        thirdClassifyId: this.data.goodsInfo.thirdClassifyId
      };
      $api.getRelationGoods(params).then(res => {
        let data = res.data.data || [];
        let arr = [];
        for (let key in data) {
          let obj = {};
          obj.relationName = key;
          data[key].forEach;
          // data[key]
          obj.list = data[key];
          // obj.list
          arr.push(obj);
        }
        this.setData({
          relationGoodsList: arr
        });
      });
    },
    // 获取套餐组合
    getGoodsCombo() {
      $api.getGoodsCombo({ goodsId: this.data.goodsId }).then(res => {
        let goodsComboList = res.data.data || [];
        goodsComboList.forEach(item => {
          const chooseNums = item.chooseNums;
          item.list = item.list.filter(item3 => item3.saleState == 2 && item3.stock);
          item.list.forEach(item2 => {
            item2.relationGoodsName =
              item2.relationGoodsName +
              (item2.relationVariantSku && item2.relationVariantSku != '无' ? '/' + item2.relationVariantSku : '');
          });
          if (chooseNums == 1) {
            const target = item.list.find(item2 => item2.stock && item2.saleState == 2);
            if (target) {
              target.selected = true;
            } else {
              this.setData({
                showNums: false
              });
            }
          } else {
            this.setData({
              showNums: false
            });
          }
        });
        this.setData({
          goodsComboList
        });
        this.judgeShowNums();
      });
    },
    // 选择规格
    selectSpec(e) {
      let val = e.target.dataset; //获取选中规格下标
      console.log(val, '这是val');
      if (val.oversold) return; //判断是否没货
      let specList = this.data.specList; //拿取规格项和规格值
      if (val.hasOwnProperty('index') && val.hasOwnProperty('index2')) {
        //判断是否存在两个key
        specList[val.index].specValList.forEach(item => {
          item.selected = false;
        });
        specList[val.index].specValList[val.index2].selected = true; //将每一个选中的规格值设置为true
        this.judgeOverSold();
      }
    },
    // 选择关联产品
    selectRelationGoods(e) {
      let { index, index2, item } = e.target.dataset;
      let relationGoodsList = this.data.relationGoodsList;
      if (item) {
        const selected = !relationGoodsList[index].list[index2].selected;
        relationGoodsList[index].list[index2].selected = selected;
        this.setData({
          relationGoodsList
        });
        this.countPrice();

        if (item.attrMark) {
          // attrMark存在表示需要获取表单信息
          this.getFormInfo(item, selected);
        }
      }
    },
    async getFormInfo(goods, selected) {
      const { goodsId, serverId, thirdClassifyId, businessId } = goods;
      const { goodsFormList, date } = this.data;
      let res = await $api.getFormItemInfo({ goodsId, serverId, thirdClassifyId, businessId });
      res = res.data.data || [];
      const id = res[0].goodsId + '-' + res[0].serverId;
      if (selected) {
        let formList = wx.getStorageSync('formList');
        formList = formList ? JSON.parse(formList) : [];
        const index = formList.findIndex(item => item.id == id);
        // 这里需要在本地缓存判断是否有相同的如果有就使用
        if (index != -1) {
          goodsFormList.push(formList[index]);
          this.setData({
            goodsFormList
          });
          return;
        }
        goodsFormList.push({
          id,
          name: res[0].goodsName || res[0].serverName,
          introduce: res[0].introduce,
          list: res
        });
      } else {
        const index = goodsFormList.findIndex(item => item.id == id);
        if (index != -1) {
          goodsFormList.splice(index, 1);
        }
      }
      this.setData({
        goodsFormList
      });
    },
    // 修改产品表单数据
    modifyFormData(e) {
      const { goodsFormList } = this.data;
      goodsFormList[e.currentTarget.dataset.index].list = e.detail.formList[0];
      this.setData({
        goodsFormList
      });
    },
    // 选择套餐组合
    selectGoodsCombo(e) {
      let val = e.target.dataset;
      if (!val.stock || val.salestate != 2) {
        return;
      }
      const { goodsComboList } = this.data;
      if (val.hasOwnProperty('index') && val.hasOwnProperty('index2')) {
        const target = goodsComboList[val.index];
        const targetList = target.list;
        const targetItem = targetList[val.index2];
        const chooseNums = target.chooseNums;
        const currentNums = targetList.filter(item => item.selected).length;
        if (chooseNums == 1) {
          targetList.forEach(item => (item.selected = false));
          targetItem.selected = !targetItem.selected;
        } else if (targetItem.selected) {
          targetItem.selected = false;
        } else if (currentNums < chooseNums) {
          targetItem.selected = true;
        } else if (currentNums >= chooseNums) {
          Toast.fail(target.comboName + '只能选择' + chooseNums + '个');
        }
        this.setData({
          goodsComboList
        });

        this.judgeShowNums();
      }
    },
    // 获取预览的图片
    getImgList() {
      const imgList = [];
      const variantMap = this.data.variantMap;
      for (let key in variantMap) {
        let item = variantMap[key];
        imgList.push({
          url: item.mainImg ? item.mainImg : this.data.goodsImage,
          desc: this.getCombineName(key) || this.data.goodsInfo.introduce
        });
      }
      this.setData({
        imgList
      });
    },
    // 每次选择规格都需要判断哪些规格是销售完了的
    judgeOverSold() {
      // 拼接规格名字、获取价格
      let specVal = '';
      let sku = '';
      this.data.specList.forEach((item, index) => {
        return item.specValList.find(item2 => {
          if (item2.selected) {
            specVal = specVal ? specVal + '、' + item2.specVal : item2.specVal;
            sku = sku ? sku + ':' + item2.specVal : String(item2.specVal);
            return true;
          }
        });
      });
      this.setData({
        specVal,
        sku,
        variantId: this.data.variantMap[sku].variantId,
        deposit: this.data.variantMap[sku].deposit,
        startFee: this.data.variantMap[sku].startFee,
        nums: 1
      });

      // 全局添加一个变体id
      app.globalData['btnList.variantId'] = this.data.variantId;

      // 获取价格
      this.countPrice();
      // 通过sku获取图片
      for (let key in this.data.variantMap) {
        if (key == sku) {
          this.setData({
            mainImg: this.data.variantMap[key].mainImg,
            introduce: this.data.variantMap[key].introduce
          });
        }
      }
      // 过滤调哪些规格组合是不能选的
      sku = sku.split(':');
      let keys = Object.keys(this.data.variantMap);
      let specList = this.data.specList;
      let length = this.data.specList.length;
      let arr = [];
      for (let i = 0; i < length; i++) {
        let arr2 = keys.filter(item => {
          return sku.every((item2, index2) => {
            if (index2 == i) return true;
            return item2 == item.split(':')[index2];
          });
        });
        if (arr2.length > 0) {
          arr2 = arr2.map(item => {
            return item.split(':')[i];
          });
        }
        arr[i] = Array.from(new Set(arr2));
      }

      specList.forEach((item, index) => {
        item.specValList.forEach(item2 => {
          if (arr[index].some(item3 => item3 == item2.specVal)) {
            item2.oversold = false;
          } else {
            item2.oversold = true;
          }
        });
      });
      this.setData({
        specList: specList
      });
      // 每次规格改变都需要购物车的数量
      // this.getShopCartData()
    },
    // 通过variantMap的key来获取规格组合名称
    getCombineName(key) {
      const arr = key.split(':');
      let name = '';
      arr.forEach((item, index) => {
        let val = this.data.specList[index].specValList.find(item2 => {
          return item2.specVal == item;
        });
        if (val) {
          name = name ? name + '、' + val.specVal : val.specVal;
        }
      });
      return name;
    },
    // 判断是否显示数量
    judgeShowNums() {
      const { goodsComboList } = this.data;
      const flag = goodsComboList.some(item => {
        const chooseNums = item.chooseNums;
        const currentNums = item.list.filter(item => item.selected).length;
        if (chooseNums > currentNums) {
          return true;
        }
      });
      this.setData({
        nums: 1, //无论是否显示都把数据变为1
        salePrice: this.data.goodsInfo.salePrice,
        showNums: flag ? false : true
      });
      this.countPrice();
    },
    // 计算价格
    countPrice() {
      // 计算参加活动后的价格
      this.calcuActive();
    },

    // 计算活动数量
    calcuActive() {
      console.log(this.data);
      let { variantMap, sku, relationGoodsList, goodsInfo, nums, activeDiscount, activeNums } = this.data;
      // 先获取选中的关联产品
      let arr = [];
      let arr2 = [];
      const skuObj = sku ? variantMap[sku] : {};
      console.log(skuObj, 'skuObj');
      if (sku) {
        // 多规格
        if (this.activeTime(skuObj)) {
          // 且在活动范围之内
          activeDiscount = parseFloat(((skuObj.active.activePrice / skuObj.price) * 10).toFixed(2)) || 0.01;
          activeNums = skuObj.active.maxNum;
        } else {
          activeDiscount = '';
          activeNums = '';
          // 做一个标记,同时添加数量
        }
        arr.push({ ...skuObj, nums });
      } else {
        // 套餐或者单品
        if (this.activeTime(goodsInfo)) {
          //且在活动范围之内
          activeDiscount = parseFloat(((goodsInfo.active.activePrice / goodsInfo.price) * 10).toFixed(2));
          activeNums = goodsInfo.active.maxNum;
        } else {
          // 做一个标记，同时添加数量
          activeDiscount = '';
          activeNums = '';
        }
        arr.push({ ...goodsInfo, nums });
      }
      arr2 = relationGoodsList
        .flatMap(item => item.list)
        .filter(item => {
          return item.selected;
        })
        .map(item => ({ nums: 1, ...item }));
      arr = arr.concat(arr2);
      arr2 = [];
      // 排序把所有相同活动的数据放在一起,没有活动的数据放在一个数组里面
      arr.forEach(item => {
        if (this.activeTime(item)) {
          // 处于活动期间
          const i = arr2.findIndex(item2 => item2.some(item3 => item3.active.activeId == item.active.activeId));
          if (i != -1) {
            arr2[i].push(item);
          } else {
            if (arr2.length == 0) {
              arr2[0] = [];
              arr2[1] = [item];
            } else {
              arr2[arr2.length] = [item];
            }
          }
        } else {
          // 不处于活动期间,
          if (arr2.length == 0) {
            arr2[0] = [item];
          } else {
            arr2[0].push(item);
          }
        }
      });
      // 二维数组arr2里面的每一个数组进行差价排序
      arr2.forEach((item, index) => {
        if (index) {
          // 索引为0的数组是没有活动的数据，不需要排序
          item.sort((a, b) => b.salePrice - b.active.activePrice - (a.salePrice - a.active.activePrice));
        }
      });
      // 之后需要给每个产品设置可享受活动的数量
      arr2.forEach((item, index) => {
        if (index) {
          let maxCount = item[0].active.maxCount;
          item.find(item2 => {
            let maxNum = item2.active.maxNum;
            if (!maxCount) {
              // 数量全部安排完了
              return true;
            }
            if (item2.nums <= maxCount) {
              if (item2.nums <= maxNum) {
                item2.activeNums = item2.nums;
              } else {
                item2.activeNums = maxNum;
              }
            } else if (maxCount < item2.nums) {
              if (maxCount >= maxNum) {
                item2.activeNums = maxNum;
              } else {
                item2.activeNums = maxCount;
              }
            }
            maxCount = maxCount - item2.activeNums;
          });
        }
      });
      // 最后拍平二维数组为一维数组，计算价格
      arr2 = arr2.flat();
      let salePrice = 0;
      let deposit = 0;
      arr2.forEach(item => {
        const add = item.activeNums
          ? item.active.activePrice * item.activeNums + item.salePrice * (item.nums - item.activeNums)
          : item.salePrice * item.nums;
        salePrice = salePrice + add;
        deposit = (item.deposit ? item.nums * item.deposit : 0) + deposit;
      });
      this.setData({
        salePrice: parseFloat(salePrice.toFixed(2)),
        deposit: deposit || deposit === 0 ? parseFloat(deposit.toFixed(2)) : '',
        activeDiscount,
        activeNums
      });
    },
    // 判断是否在活动范围之内,并计算最优的价格
    activeTime(item) {
      if (!item.active) return;
      let { beginDate, endDate } = item.active;
      beginDate = getDatetime(beginDate).getTime();
      endDate = getDatetime(endDate).getTime();
      let nowDate = new Date().getTime();
      if (nowDate > beginDate && nowDate < endDate) {
        return true;
      }
    },
    // 添加
    addNum() {
      // 对接产品如果超标就返回
      const eventId = app.globalData['btnList.eventId'];
      // 对接产品或者是时段产品就不能添加
      if (exceedMessageTip({ eventId, goods: this.data.goodsInfo })) return;
      this.setData({
        nums: ++this.data.nums
      });
      this.countPrice();
    },
    // 减少
    subNum() {
      if (this.data.nums <= 1) return;
      this.setData({
        nums: --this.data.nums
      });
      this.countPrice();
    },
    // 加入购物车
    addCart(e) {
      const { relationGoodsList, goodsInfo, goodsComboList, sku, variantMap, showNums, goodsFormList } = this.data;
      let shopCartList = wx.getStorageSync('shopCartData');
      shopCartList = shopCartList ? JSON.parse(shopCartList) : [];
      // 是对接产品，只能添加一个
      const eventId = app.globalData['btnList.eventId'];
      if (exceedMessageTip({ eventId, shopCartList })) return;
      if (!showNums) {
        Toast.fail('请按规则选择套餐');
        return;
      }
      // 空包产品
      if (goodsInfo.huskFlag) {
        // 空包产品
        const flag = relationGoodsList.find(item => {
          return item.list.some(item2 => item2.selected);
        });
        if (!flag) {
          Toast.fail('请至少选择一项关联产品');
          return;
        }
      }

      // 如果存在表单数据需要那么需要校验
      if (goodsFormList.length > 0) {
        for (let key in goodsFormList) {
          if (!this.selectComponent('.custom-form' + key).validate()) {
            return;
          }
        }
        let formList = wx.getStorageSync('formList');
        formList = formList ? JSON.parse(formList) : [];
        wx.setStorageSync('formList', JSON.stringify(formList.concat(goodsFormList)));
      }

      let obj = {};
      if (goodsInfo.variantState == 1 && goodsInfo.goodsType != 2 && !goodsInfo.huskFlag) {
        if (isDeferConfirmWay(goodsInfo.businessConfirmWay, shopCartList)) return;
        if (exceedMessageTip({ goods: goodsInfo, shopCartList })) return;
        // 单品非空包产品
        obj = {
          goodsId: this.data.goodsId,
          nums: this.data.nums,
          mainImage: this.data.goodsImage
        };
        this.triggerEvent('addNum', Object.assign({}, goodsInfo, obj));
      } else if (goodsInfo.variantState == 2) {
        if (isDeferConfirmWay(goodsInfo.businessConfirmWay, shopCartList)) return;
        if (exceedMessageTip({ goods: goodsInfo, shopCartList })) return;
        // 多规格
        obj = {
          variantId: this.data.variantId,
          goodsId: this.data.goodsId,
          specVal: this.data.specVal,
          nums: this.data.nums,
          // businessConfirmWay: goodsInfo.businessConfirmWay,
          salePrice: this.data.variantMap[this.data.sku].salePrice,
          price: this.data.variantMap[this.data.sku].price,
          deposit: this.data.variantMap[this.data.sku].deposit,
          mainImage: this.data.mainImg,
          active: variantMap[sku].active
        };
        this.triggerEvent('addNum', Object.assign({}, goodsInfo, obj));
      }

      // 关联产品
      for (let item of relationGoodsList) {
        for (let item2 of item.list) {
          if (item2.selected) {
            if (isDeferConfirmWay(goodsInfo.businessConfirmWay, shopCartList)) return;
            if (exceedMessageTip({ goods: goodsInfo, shopCartList })) return;
            const temp = Object.assign({
              ...item2,
              businessConfirmWay: goodsInfo.businessConfirmWay,
              mainImage: item2.mainImg,
              nums: 1
            });
            this.triggerEvent('addNum', temp);
          }
        }
      }
      // 套餐组合
      if (goodsInfo.goodsType == 2) {
        let relationGoodsNames = '';
				const relationVariantIds = [];
				
        for (let item of goodsComboList) {
          for (let item2 of item.list) {
            if (item2.selected) {
              if (isDeferConfirmWay(item2.businessConfirmWay, shopCartList)) return;
							if (exceedMessageTip({ goods: goodsInfo, shopCartList })) return;
							
              relationVariantIds.push(item2.relationVariantId);
              relationGoodsNames = relationGoodsNames
                ? relationGoodsNames + '、' + item2.relationGoodsName
                : item2.relationGoodsName;
            }
          }
        }
        obj = {
          goodsId: this.data.goodsId,
          nums: this.data.nums,
          relationGoodsNames,
          relationVariantIds
        };
        this.triggerEvent('addNum', Object.assign({}, goodsInfo, obj));
      }
      this.addAni(e.touches[0]);
    },
    // 是否售罄
    // timeOut(goods) {
    //   if (!goods.goodsHours || goods.goodsHours && !goods.goodsHours.length) return
    //   const res = goods.goodsHours.some(item => {
    //     let time = new Date()
    //     let begin = new Date()
    //     let end = new Date()
    //     const arr = item.beginHours.split(":").map(item => Number(item))
    //     const arr2 = item.endHours.split(":").map(item => Number(item))
    //     begin.setHours(arr[0])
    //     begin.setMinutes(arr[1])
    //     end.setHours(arr2[0])
    //     end.setMinutes(arr2[1])
    //     return time.getTime() > begin.getTime() && time.getTime() < end.getTime()
    //   })
    // },
    // 添加动画
    addAni({ clientX, clientY }) {
      const { top, right } = this.data.shopCartPosition;
      this.setData({
        showDot: true,
        dotClientX: clientX,
        dotClientY: clientY
      });
      setTimeout(() => {
        const addAnimation2 = wx
          .createAnimation()
          .top(top)
          .left(right - 20)
          .step({ duration: 200, timingFunction: 'ease-in' });
        this.setData({
          addAnimation2: addAnimation2.export()
        });
        setTimeout(() => {
          this.setData({
            showDot: false,
            addAnimation2: null
          });
        }, 200);
      }, 100);
    },
    close() {
      this.setData({
        show: false
      });
    },
    // 直接下单
    toSubmitOrderPage() {
      const { goodsInfo, relationGoodsList, goodsComboList, showNums, goodsFormList } = this.data;
      if (!showNums) {
        Toast.fail('请按规则选择套餐');
        return;
      }
      if (goodsInfo.huskFlag) {
        const flag = relationGoodsList.find(item => {
          return item.list.some(item2 => item2.selected);
        });
        if (!flag) {
          Toast.fail('请至少选择一项关联产品');
          return;
        }
      }

      const arr = [];
      if (!goodsInfo.huskFlag) {
        const item = { ...goodsInfo };
        item.nums = this.data.nums;
        // 多规格
        if (this.data.goodsInfo.variantState == 2) {
          item.salePrice = this.data.variantMap[this.data.sku].salePrice;
          item.specVal = this.data.specVal;
          item.variantId = this.data.variantId;
          item.mainImage = this.data.mainImg;
        }
        // 套餐组合
        if (goodsInfo.goodsType == 2) {
          let relationGoodsNames = '';
          const relationVariantIds = [];
          goodsComboList.forEach(item => {
            item.list.forEach(item2 => {
              if (item2.selected) {
                relationVariantIds.push(item2.relationVariantId);
                relationGoodsNames = relationGoodsNames
                  ? relationGoodsNames + '、' + item2.relationGoodsName
                  : item2.relationGoodsName;
              }
            });
          });
          item.relationVariantIds = relationVariantIds;
          item.relationGoodsNames = relationGoodsNames;
        }
        arr.push(item);
      }
      // 关联产品
      relationGoodsList.forEach(item => {
        item.list.forEach(item2 => {
          if (item2.selected) {
            let temp = { ...item2 };
            temp.nums = 1;
            temp.mainImage = temp.mainImg;
            arr.push({ ...temp });
          }
        });
      });
      app.globalData.goodsList = arr;

      if (goodsFormList.length > 0) {
        for (let key in goodsFormList) {
          if (!this.selectComponent('.custom-form' + key).validate()) {
            return;
          }
        }
      }
      app.globalData.tempFormList = goodsFormList;
      wx.navigateTo({
        url: '/subcontract/home/pages/submitOrder/index'
      });
    },
    // 预览图片
    previewImage() {
      let imgIndex = -1;
      let variantMap = this.data.variantMap;
      if (variantMap) {
        for (let key in variantMap) {
          imgIndex++;
          if (variantMap[key].sku == this.data.sku) {
            break;
          }
        }
      } else {
        let goodsInfo = this.data.goodsInfo;
        this.data.imgList = [
          {
            url: this.data.goodsImage,
            desc: goodsInfo.introduce
          }
        ];
        this.setData({
          imgList: this.data.imgList
        });
        imgIndex = 0;
      }
      this.setData({
        showImgePreivew: true,
        imgIndex
      });
    }
  }
});
